<?php

namespace App\Http\Controllers;

use App\Http\Controllers\Controller;
use App\Student;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Hash;

class StudentController extends Controller {
   
    public function createStudent(Request $request) 
    {

    	    $this->validate($request, [
	          'name' => 'required',
	          'password' => 'required'
            ]);

    	    $data = $request->only('name','password');
	        $stu = new Student();
	        $stu->student_name = $data['name'];
	        $stu->password = $data['password'];
	        $bool=$stu->save();
	        if($bool){
	        	return response()->json(['success' => true, 'msg' => 'register success']);
	        }else{
	        	return response()->json(['success' => false, 'msg' => 'register fail']);
	        }
    }
}